package com.redxiii.util.gui.config;

import org.apache.commons.configuration.PropertiesConfiguration;

import com.redxiii.util.gui.progress.ProgressAction;
import com.redxiii.util.gui.progress.ProgressStatus;

public class ProgressFrame extends Frame {

	private ProgressAction action;
	private ProgressStatus status;
	
	public ProgressFrame(String description, ProgressAction action) {
		super(description, new PropertiesConfiguration());
		this.action = action;
	}
	
	public void setStatus(ProgressStatus status) {
		this.status = status;
	}
	
	public boolean runAction() { 
		try {
			status.updateStatus(0, 0, 1, "");
			status.updateStatus(1, 0, 1, "");
			status.updateStatus(2, 0, 1, "");
			
			action.init(status);
			return action.call();
		} catch (Exception e) {
			return false;
		}
	}

}
